<script>
import { DatePicker, DatePickerOptions } from "element-ui";
import Date from "@/utils/datetime.js";
import vm from "@/main.js";
export default {
  name: "DateRangePicker",
  mixins: [DatePicker],
  props: {
    type: {
      type: String,
      default: "daterange",
    },
    valueFormat: {
      type: String,
      default: "timestamp",
    },
    // defaultTime: {
    //   type: Array,
    //   default: (_) => ["00:00:00", "23:59:59"],
    // },
    pickerOptions: {
      type: DatePickerOptions,
      default: (_) => {
        return {
          shortcuts: [
            {
              text: vm.$t("Home.index28"),
              onClick(picker) {
                const start = new Date(new Date().toLocaleDateString()).daysAgo(7);
                picker.$emit("pick", [start, new Date()]);
              },
            },
            {
              text: vm.$t("Home.index29"),
              onClick(picker) {
                const start = new Date(new Date().toLocaleDateString()).daysAgo(30);
                picker.$emit("pick", [start, new Date()]);
              },
            },
          ],
          disabledDate(time) {
            return time.getTime() > Date.now();
          },
        };
      },
    },
    size: {
      type: String,
      default: "medium",
    },
    rangeSeparator: {
      type: String,
      default: ":",
    },
    startPlaceholder: {
      type: String,
      default: vm.$t("Home.index26"),
    },
    endPlaceholder: {
      type: String,
      default: vm.$t("Home.index27"),
    },
  },
};
</script>
<style lang="scss" scoped>
.el-range-editor.el-input__inner {
  width: 250px;
}
</style>